// 检测 页面是否有操作
import { localremovetoken } from '@/utils/auth'
import { logout_timeoutApi } from '@/api/config.js'
export async function monitorfn(v) {
  // 一段时间没有操作自动退出
  const num = (await logout_timeoutApi('logout_timeout')).data.data || 60
  let num2 = num * 60
  document.addEventListener('mousemove', () => {
    num2 = num * 60
    // console.log(num2)
  })
  const time = setInterval(() => {
    // console.log(v.$route)
    if (v.$route.path !== '/login') {
      num2--
      if (num2 === 0) {
        localremovetoken()
        location.reload()
        // v.$router.push('/login')
      }
    } else {
      clearInterval(time)
    }
    // console.log(num2, 'num2--')
  }, 1000)
}
